## Script (Python) "deleteObjects"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind state=state
##bind subpath=traverse_subpath
##parameters=
##title=
##


#from Products.ePubBook import ePubBookMessageFactory as _
#message = ''
req = context.REQUEST
context_path = '/'.join(context.getPhysicalPath())
for k in req.keys():
    if k.find('epubpage-')==0:
        id = k[9:]
        id_path = context_path+'/'+id
        page = context.restrictedTraverse(id_path)
        if page==None:
            continue
        new_directoryname = req.get(k)
        if new_directoryname != page.getDirectoryname():
            page.setDirectoryname(new_directoryname)
            page.reindexObject()
#            message=message+' '+id+'--'+new_directoryname

#context.plone_utils.addPortalMessage(message)

#status='failure'
#message=_(u'Please select one or more items to delete.')
#
#
#failure = {}
#success = []
#
#for id in paths:
#    try:
#        context.manage_delObjects([id])
#        success.append('%s (%s)' % (id, id))
#    except Exception, e:
#        failure[id]= e
#            
#if success:
#    status='success'
#    message = _(u'Item(s) deleted.')
#
#if failure:
#    message = _(u'${items} could not be deleted.',
#                mapping={u'items' : ', '.join(failure.keys())})
#
#context.plone_utils.addPortalMessage(message)
#
return state.set(status='success')
